package common.data.admin
{
	import common.model.WqAdvice;
	import common.model.WqTradeRole;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	/**
	 * 命令服务类
	 */
	public class AdminService extends RemoteObject
	{
		public var findAllCompanyCallBack:Function;
		public var saveCompanyCallBack:Function;
		public var deleteCompanyCallBack:Function;
		
		public var findAllAdminCallBack:Function;
		public var saveAdminCallBack:Function;
		public var deleteAdminCallBack:Function;
		
		public var analyseLocationCallBack:Function;
		public var getComListByZcodeCallBack:Function;
		
		public var analyseTradeCallBack:Function;
		public var getComListByTradeCallBack:Function;
		
		public var totalSysVisitedCallBack:Function;
		
		public var findServiceTimeCallBack:Function;
		public var findPhoneByCompanyIdCallBack:Function;
		public var setLimitTimeCallBack:Function;
		public var handleOverTimePhonesCallBack:Function;
		
		public var saveAdviceCallBack:Function;
		public var deleteAdviceCallBack:Function;
		public var findAllAdviceCallBack:Function;
		public var handledAdvicesCallBack:Function;
		
		public var saveTradeRoleCallBack:Function;
		public var deleteTradeRoleCallBack:Function;
		public var findAllTradeRoleCallBack:Function;
		
		public function AdminService() {
			super("adminService");
			this.showBusyCursor = true;
			
			this.getOperation("findAllCompany").addEventListener(ResultEvent.RESULT,findAllCompanyResult,false,0,true);
			this.getOperation("saveCompany").addEventListener(ResultEvent.RESULT,saveCompanyResult,false,0,true);
			this.getOperation("deleteCompany").addEventListener(ResultEvent.RESULT,deleteCompanyResult,false,0,true);
			
			this.getOperation("findAllAdmin").addEventListener(ResultEvent.RESULT,findAllAdminResult,false,0,true);
			this.getOperation("saveAdmin").addEventListener(ResultEvent.RESULT,saveAdminResult,false,0,true);
			this.getOperation("deleteAdmin").addEventListener(ResultEvent.RESULT,deleteAdminResult,false,0,true);
			
			this.getOperation("analyseLocation").addEventListener(ResultEvent.RESULT,analyseLocationResult,false,0,true);
			this.getOperation("getComListByZcode").addEventListener(ResultEvent.RESULT,getComListByZcodeResult,false,0,true);
			
			this.getOperation("analyseTrade").addEventListener(ResultEvent.RESULT,analyseTradeResult,false,0,true);
			this.getOperation("getComListByTrade").addEventListener(ResultEvent.RESULT,getComListByTradeResult,false,0,true);
			
			this.getOperation("totalSysVisited").addEventListener(ResultEvent.RESULT,totalSysVisitedResult,false,0,true);
			
			this.getOperation("findServiceTime").addEventListener(ResultEvent.RESULT,findServiceTimeResult,false,0,true);
			this.getOperation("findPhoneByCompanyId").addEventListener(ResultEvent.RESULT,findPhoneByCompanyIdResult,false,0,true);
			this.getOperation("setLimitTime").addEventListener(ResultEvent.RESULT,setLimitTimeResult,false,0,true);
			this.getOperation("handleOverTimePhones").addEventListener(ResultEvent.RESULT,handleOverTimePhonesResult,false,0,true);
			
			this.getOperation("saveAdvice").addEventListener(ResultEvent.RESULT,saveAdviceResult,false,0,true);
			this.getOperation("findAllAdvice").addEventListener(ResultEvent.RESULT,findAllAdviceResult,false,0,true);
			this.getOperation("handledAdvices").addEventListener(ResultEvent.RESULT,handledAdvicesResult,false,0,true);
			
			this.getOperation("saveTradeRole").addEventListener(ResultEvent.RESULT,saveTradeRoleResult,false,0,true);
			this.getOperation("findAllTradeRole").addEventListener(ResultEvent.RESULT,findAllTradeRoleResult,false,0,true);
			this.getOperation("deleteTradeRole").addEventListener(ResultEvent.RESULT,deleteTradeRoleResult,false,0,true);
			
		}
		
		public function findAllCompany():void{
			this.getOperation("findAllCompany").send();
		}
		
		public function saveCompany(company:Object):void{
			this.getOperation("saveCompany").send(company);
		}
		public function deleteCompany(id:String):void{
			this.getOperation("deleteCompany").send(id);
		}
		
		public function findAllAdmin():void{
			this.getOperation("findAllAdmin").send();
		}
		public function saveAdmin(Admin:Object):void{
			this.getOperation("saveAdmin").send(Admin);
		}
		public function deleteAdmin(id:String):void{
			this.getOperation("deleteAdmin").send(id);
		}
		public function analyseLocation(zcode:String):void{
			this.getOperation("analyseLocation").send(zcode,null);
		}
		public function getComListByZcode(zcode:String):void{
			this.getOperation("getComListByZcode").send(zcode,null);
		}
		public function analyseTrade():void{
			this.getOperation("analyseTrade").send();
		}
		public function getComListByTrade(tradeId:String):void{
			this.getOperation("getComListByTrade").send(tradeId);
		}
		public function findServiceTime():void{
			this.getOperation("findServiceTime").send();
		}
		public function findPhoneByCompanyId(companyId:String):void{
			this.getOperation("findPhoneByCompanyId").send(companyId);
		}
		public function setLimitTime(phones:ArrayCollection,date:String):void{
			this.getOperation("setLimitTime").send(phones,date);
		}
		public function handleOverTimePhones(phones:ArrayCollection):void{
			this.getOperation("handleOverTimePhones").send(phones);
		}
		public function totalSysVisited(startTime:String,endTime:String):void{
			this.getOperation("totalSysVisited").send(startTime,endTime);
		}
		public function saveAdvice(advice:WqAdvice):void{
			this.getOperation("saveAdvice").send(advice);
		}
		public function findAllAdvice():void{
			this.getOperation("findAllAdvice").send();
		}
		public function handledAdvices(advices:Array):void{
			this.getOperation("handledAdvices").send(advices);
		}
		public function deleteAdvice(advice:WqAdvice):void{
			this.getOperation("deleteAdvice").send(advice);
		}
		
		public function saveTradeRole(trade:WqTradeRole):void{
			this.getOperation("saveTradeRole").send(trade);
		}
		public function findAllTradeRole():void{
			this.getOperation("findAllTradeRole").send();
		}
		public function deleteTradeRole(tradeRoleId:String):void{
			this.getOperation("deleteTradeRole").send(tradeRoleId);
		}
		
		//回调点名命令
		private function findAllCompanyResult(e:ResultEvent):void{
			try{
				findAllCompanyCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//回调点名命令
		private function saveCompanyResult(e:ResultEvent):void{
			try{
				saveCompanyCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//回调点名命令
		private function deleteCompanyResult(e:ResultEvent):void{
			try{
				deleteCompanyCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//回调点名命令
		private function findAllAdminResult(e:ResultEvent):void{
			try{
				findAllAdminCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		//回调点名命令
		private function saveAdminResult(e:ResultEvent):void{
			try{
				saveAdminCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//回调点名命令
		private function deleteAdminResult(e:ResultEvent):void{
			try{
				deleteAdminCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function analyseLocationResult(e:ResultEvent):void{
			try{
				analyseLocationCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function getComListByZcodeResult(e:ResultEvent):void{
			try{
				getComListByZcodeCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function analyseTradeResult(e:ResultEvent):void{
			try{
				analyseTradeCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function getComListByTradeResult(e:ResultEvent):void{
			try{
				getComListByTradeCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function findServiceTimeResult(e:ResultEvent):void{
			try{
				findServiceTimeCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function findPhoneByCompanyIdResult(e:ResultEvent):void{
			try{
				findPhoneByCompanyIdCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function setLimitTimeResult(e:ResultEvent):void{
			try{
				setLimitTimeCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function handleOverTimePhonesResult(e:ResultEvent):void{
			try{
				handleOverTimePhonesCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function totalSysVisitedResult(e:ResultEvent):void{
			try{
				totalSysVisitedCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function saveAdviceResult(e:ResultEvent):void{
			try{
				saveAdviceCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function findAllAdviceResult(e:ResultEvent):void{
			try{
				findAllAdviceCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function handledAdvicesResult(e:ResultEvent):void{
			try{
				handledAdvicesCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function deleteAdviceResult(e:ResultEvent):void{
			try{
				deleteAdviceCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		private function saveTradeRoleResult(e:ResultEvent):void{
			try{
				saveTradeRoleCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function findAllTradeRoleResult(e:ResultEvent):void{
			try{
				findAllTradeRoleCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function deleteTradeRoleResult(e:ResultEvent):void{
			try{
				deleteTradeRoleCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
	}
}	